
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>产品管理</title>
    <#include "../common/link.ftl"/>
    <script>
        $(function () {
            $('.btn-input').click(function () {
                $('#editForm')[0].reset();
                $('input[name=id]').val("");
                var jsonStr = $(this).data('json');
                //console.log(jsonStr)
                if(jsonStr != null){
                    $('input[name=id]').val(jsonStr.id);
                    $('input[name=name]').val(jsonStr.name);
                    $('input[name=price]').val(jsonStr.price);
                    $('input[name=remark]').val(jsonStr.remark);
                }

                $('#editModal').modal('show');
            });
            $('.submitBtn').click(function () {
                //$('#editForm').submit();
                $('#editForm').ajaxSubmit(function (data) {
                    handleData(data);
                })
            });

        });


    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl"/>
    <!--菜单回显-->
<#--    <c:set var="currentMenu" value="product"/>-->
    <#assign currentMenu = "product"/>
    <#include "../common/menu.ftl"/>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>产品管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/product/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="javascript:;" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>产品名称</th>
                            <th>产品价格</th>
                            <th>产品备注</th>
                            <th>操作</th>
                        </tr>
<#--                        <c:forEach items="${result.list!}" var="entity" varStatus="vs">-->
                            <#list result.list as entity>
                            <tr>
                                <td>${entity_index+1}</td>
                                <td>${(entity.name)!}</td>
                                <td>${(entity.price)!}</td>
                                <td>${(entity.remark)!}</td>
                                <td>
                                    <a class="btn btn-info btn-xs btn-input" href="javascript:;" data-json='${entity.json}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                    <a href="javascript:;" data-url='/product/delete.do?id=${entity.id}' class="btn btn-danger btn-xs btn-delete">
                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                    </a>
                                </td>
                            </tr>
                            </#list>
<#--                        </c:forEach>-->
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl"/>
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl"/>
</div>


<#--产品编辑模态框-->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span> </button>
                <h4 class="modal-title">产品编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/product/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" value="" name="id">
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">产品名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name" value="" placeholder="请输入产品名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">产品价格：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="price" value="" placeholder="请输入产品价格">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">产品备注：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="remark" value="" placeholder="请输入产品备注">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary submitBtn" >保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
